﻿using System;
using UnityEngine;

namespace Studio
{
	// Token: 0x020005AB RID: 1451
	public class ManipulatePanelCtrl : MonoBehaviour
	{
		// Token: 0x17000474 RID: 1140
		// (get) Token: 0x060024F0 RID: 9456 RVA: 0x000DC000 File Offset: 0x000DA200
		// (set) Token: 0x060024F1 RID: 9457 RVA: 0x000DC010 File Offset: 0x000DA210
		public bool active
		{
			get
			{
				return base.gameObject.activeSelf;
			}
			set
			{
				base.gameObject.SetActive(value);
				if (base.gameObject.activeSelf)
				{
					this.SetActive();
				}
				else
				{
					this.Deactivate();
				}
			}
		}

		// Token: 0x17000475 RID: 1141
		// (get) Token: 0x060024F2 RID: 9458 RVA: 0x000DC040 File Offset: 0x000DA240
		// (set) Token: 0x060024F3 RID: 9459 RVA: 0x000DC048 File Offset: 0x000DA248
		private ManipulatePanelCtrl.RootInfo[] rootPanel { get; set; }

		// Token: 0x17000476 RID: 1142
		// (get) Token: 0x060024F4 RID: 9460 RVA: 0x000DC054 File Offset: 0x000DA254
		// (set) Token: 0x060024F5 RID: 9461 RVA: 0x000DC05C File Offset: 0x000DA25C
		public int kind { get; private set; }

		// Token: 0x17000477 RID: 1143
		// (set) Token: 0x060024F6 RID: 9462 RVA: 0x000DC068 File Offset: 0x000DA268
		public ObjectCtrlInfo objectCtrlInfo
		{
			set
			{
				if (value is OCIChar)
				{
					this.kind = 0;
				}
				else if (value is OCIItem)
				{
					this.kind = 1;
				}
				else if (value is OCILight)
				{
					this.kind = 2;
				}
				else if (value is OCIFolder)
				{
					this.kind = 3;
				}
				else
				{
					this.kind = -1;
				}
				this.charaPanelInfo.mpCharCtrl.ociChar = (value as OCIChar);
				this.itemPanelInfo.mpItemCtrl.ociItem = (value as OCIItem);
				this.lightPanelInfo.mpLightCtrl.ociLight = (value as OCILight);
				this.folderPanelInfo.mpFolderCtrl.ociFolder = (value as OCIFolder);
			}
		}

		// Token: 0x060024F7 RID: 9463 RVA: 0x000DC130 File Offset: 0x000DA330
		public void OnSelect(TreeNodeObject _node)
		{
			Singleton<Studio>.Instance.colorPaletteCtrl.visible = false;
			ObjectCtrlInfo objectCtrlInfo = this.TryGetLoop(_node);
			this.kind = ((objectCtrlInfo != null) ? objectCtrlInfo.kind : -1);
			switch (this.kind)
			{
			case 0:
				this.charaPanelInfo.mpCharCtrl.ociChar = (objectCtrlInfo as OCIChar);
				break;
			case 1:
				this.itemPanelInfo.mpItemCtrl.ociItem = (objectCtrlInfo as OCIItem);
				break;
			case 2:
				this.lightPanelInfo.mpLightCtrl.ociLight = (objectCtrlInfo as OCILight);
				break;
			case 3:
				this.folderPanelInfo.mpFolderCtrl.ociFolder = (objectCtrlInfo as OCIFolder);
				break;
			}
			if (this.active)
			{
				this.SetActive();
			}
		}

		// Token: 0x060024F8 RID: 9464 RVA: 0x000DC214 File Offset: 0x000DA414
		private void SetActive()
		{
			for (int i = 0; i < this.rootPanel.Length; i++)
			{
				this.rootPanel[i].active = (i == this.kind);
			}
		}

		// Token: 0x060024F9 RID: 9465 RVA: 0x000DC250 File Offset: 0x000DA450
		private void Deactivate()
		{
			for (int i = 0; i < this.rootPanel.Length; i++)
			{
				this.rootPanel[i].active = false;
			}
		}

		// Token: 0x060024FA RID: 9466 RVA: 0x000DC284 File Offset: 0x000DA484
		public void OnDelete(TreeNodeObject _node)
		{
			this.kind = -1;
			this.SetActive();
		}

		// Token: 0x060024FB RID: 9467 RVA: 0x000DC294 File Offset: 0x000DA494
		private ObjectCtrlInfo TryGetLoop(TreeNodeObject _node)
		{
			if (_node == null)
			{
				return null;
			}
			ObjectCtrlInfo result = null;
			if (Singleton<Studio>.Instance.dicInfo.TryGetValue(_node, out result))
			{
				return result;
			}
			return this.TryGetLoop(_node.parent);
		}

		// Token: 0x060024FC RID: 9468 RVA: 0x000DC2D8 File Offset: 0x000DA4D8
		private void Awake()
		{
			this.rootPanel = new ManipulatePanelCtrl.RootInfo[]
			{
				this.charaPanelInfo,
				this.itemPanelInfo,
				this.lightPanelInfo,
				this.folderPanelInfo
			};
			this.kind = -1;
			this.SetActive();
			TreeNodeCtrl treeNodeCtrl = Singleton<Studio>.Instance.treeNodeCtrl;
			treeNodeCtrl.onSelect = (Action<TreeNodeObject>)Delegate.Combine(treeNodeCtrl.onSelect, new Action<TreeNodeObject>(this.OnSelect));
			TreeNodeCtrl treeNodeCtrl2 = Singleton<Studio>.Instance.treeNodeCtrl;
			treeNodeCtrl2.onDelete = (Action<TreeNodeObject>)Delegate.Combine(treeNodeCtrl2.onDelete, new Action<TreeNodeObject>(this.OnDelete));
		}

		// Token: 0x04002590 RID: 9616
		[SerializeField]
		private ManipulatePanelCtrl.CharaPanelInfo charaPanelInfo = new ManipulatePanelCtrl.CharaPanelInfo();

		// Token: 0x04002591 RID: 9617
		[SerializeField]
		private ManipulatePanelCtrl.ItemPanelInfo itemPanelInfo = new ManipulatePanelCtrl.ItemPanelInfo();

		// Token: 0x04002592 RID: 9618
		[SerializeField]
		private ManipulatePanelCtrl.LightPanelInfo lightPanelInfo = new ManipulatePanelCtrl.LightPanelInfo();

		// Token: 0x04002593 RID: 9619
		[SerializeField]
		private ManipulatePanelCtrl.FolderPanelInfo folderPanelInfo = new ManipulatePanelCtrl.FolderPanelInfo();

		// Token: 0x020005AC RID: 1452
		[Serializable]
		private class RootInfo
		{
			// Token: 0x17000478 RID: 1144
			// (set) Token: 0x060024FE RID: 9470 RVA: 0x000DC380 File Offset: 0x000DA580
			public virtual bool active
			{
				set
				{
					if (this.root.activeSelf != value)
					{
						this.root.SetActive(value);
					}
				}
			}

			// Token: 0x04002596 RID: 9622
			public GameObject root;
		}

		// Token: 0x020005AD RID: 1453
		[Serializable]
		private class CharaPanelInfo : ManipulatePanelCtrl.RootInfo
		{
			// Token: 0x17000479 RID: 1145
			// (get) Token: 0x06002500 RID: 9472 RVA: 0x000DC3A8 File Offset: 0x000DA5A8
			public MPCharCtrl mpCharCtrl
			{
				get
				{
					if (this.m_MPCharCtrl == null)
					{
						this.m_MPCharCtrl = this.root.GetComponent<MPCharCtrl>();
					}
					return this.m_MPCharCtrl;
				}
			}

			// Token: 0x1700047A RID: 1146
			// (set) Token: 0x06002501 RID: 9473 RVA: 0x000DC3D4 File Offset: 0x000DA5D4
			public override bool active
			{
				set
				{
					this.mpCharCtrl.active = value;
				}
			}

			// Token: 0x04002597 RID: 9623
			private MPCharCtrl m_MPCharCtrl;
		}

		// Token: 0x020005AE RID: 1454
		[Serializable]
		private class ItemPanelInfo : ManipulatePanelCtrl.RootInfo
		{
			// Token: 0x1700047B RID: 1147
			// (get) Token: 0x06002503 RID: 9475 RVA: 0x000DC3EC File Offset: 0x000DA5EC
			public MPItemCtrl mpItemCtrl
			{
				get
				{
					if (this.m_MPItemCtrl == null)
					{
						this.m_MPItemCtrl = this.root.GetComponent<MPItemCtrl>();
					}
					return this.m_MPItemCtrl;
				}
			}

			// Token: 0x1700047C RID: 1148
			// (set) Token: 0x06002504 RID: 9476 RVA: 0x000DC418 File Offset: 0x000DA618
			public override bool active
			{
				set
				{
					this.mpItemCtrl.active = value;
				}
			}

			// Token: 0x04002598 RID: 9624
			private MPItemCtrl m_MPItemCtrl;
		}

		// Token: 0x020005AF RID: 1455
		[Serializable]
		private class LightPanelInfo : ManipulatePanelCtrl.RootInfo
		{
			// Token: 0x1700047D RID: 1149
			// (get) Token: 0x06002506 RID: 9478 RVA: 0x000DC430 File Offset: 0x000DA630
			public MPLightCtrl mpLightCtrl
			{
				get
				{
					if (this.m_MPLightCtrl == null)
					{
						this.m_MPLightCtrl = this.root.GetComponent<MPLightCtrl>();
					}
					return this.m_MPLightCtrl;
				}
			}

			// Token: 0x1700047E RID: 1150
			// (set) Token: 0x06002507 RID: 9479 RVA: 0x000DC45C File Offset: 0x000DA65C
			public override bool active
			{
				set
				{
					this.mpLightCtrl.active = value;
				}
			}

			// Token: 0x04002599 RID: 9625
			private MPLightCtrl m_MPLightCtrl;
		}

		// Token: 0x020005B0 RID: 1456
		[Serializable]
		private class FolderPanelInfo : ManipulatePanelCtrl.RootInfo
		{
			// Token: 0x1700047F RID: 1151
			// (get) Token: 0x06002509 RID: 9481 RVA: 0x000DC474 File Offset: 0x000DA674
			public MPFolderCtrl mpFolderCtrl
			{
				get
				{
					if (this.m_MPFolderCtrl == null)
					{
						this.m_MPFolderCtrl = this.root.GetComponent<MPFolderCtrl>();
					}
					return this.m_MPFolderCtrl;
				}
			}

			// Token: 0x17000480 RID: 1152
			// (set) Token: 0x0600250A RID: 9482 RVA: 0x000DC4A0 File Offset: 0x000DA6A0
			public override bool active
			{
				set
				{
					this.mpFolderCtrl.active = value;
				}
			}

			// Token: 0x0400259A RID: 9626
			private MPFolderCtrl m_MPFolderCtrl;
		}
	}
}
